package com.spring.framework.ioc.xml;

import com.spring.framework.model.learn.ReflectWarning;
import com.spring.framework.model.learn.School;
import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import java.util.Arrays;

/**
 * @author xuweizhi
 */
public class SpringCoreFirst extends ReflectWarning {

	public static void main(String[] args) {
		ApplicationContext ac = new ClassPathXmlApplicationContext("config/ioc/spring-config.xml");
		School school = (School) ac.getBean("school");
		School school1 = ac.getBean("school", School.class);

		System.out.println(school);
		System.out.println(school1);

		System.out.println(school.getHello());
		System.out.println(school1.getHello());
	}

	@Test
	public void test(){
		ApplicationContext ac = new ClassPathXmlApplicationContext("config/ioc/spring-config.xml");
		System.out.println(Arrays.toString(ac.getBeanDefinitionNames()));

		School helloSpring0 = ac.getBean("com.spring.framework.model.learn.School#1", School.class);
		School helloSpring1 = ac.getBean("school", School.class);
		School helloSpring4 = ac.getBean("school2", School.class);
		School helloSpring2 = ac.getBean("com.spring.framework.model.learn.School#0", School.class);
		School helloSpring3 = ac.getBean("com.spring.framework.model.learn.School#2", School.class);

		System.out.println(helloSpring0);
		System.out.println(helloSpring1);
		System.out.println(helloSpring4);
		System.out.println(helloSpring2);
		System.out.println(helloSpring3);

		System.out.println(Arrays.toString(ac.getBeanDefinitionNames()));
	}


}
